package com.wxs.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wxs.entity.Event;
import com.wxs.entity.Save;
import com.wxs.service.EVService;
import com.wxs.service.RoomService;
import com.wy.common.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class EVController {
	@Autowired
	RoomService roomService;

	@RequestMapping("/roomlist")
    public ResultCode roomlist(){
		return  roomService.list();
	}

	@Autowired
	EVService evService;

//	列表分页模糊查询	
	@RequestMapping("/findev")
	public PageInfo<Event> findev(@RequestParam(defaultValue="1")Integer pageNum,
			Event event){
		PageHelper.startPage(pageNum, 3);
		System.out.println(event.getCgridding()+"----------------------------------------------");
		List<Event> list = evService.findev(event);
		PageInfo<Event> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}
	
	@RequestMapping("/findtype")
	public List<Event> findtype(){
		return evService.findtype();
	}
	
	@RequestMapping("/del")
	public int del(@RequestBody Integer[] ids) {
		int result = 0;
		
		result = evService.del(ids);
		return result;
	}
	@RequestMapping("/add")
	public int add(@RequestBody Save save) {
		int result = 0;
		result = evService.add(save);
		return result;
	}
	@RequestMapping("/du")
	public void du(@RequestBody String id) {
		
		evService.du(id);
	}
	
	@RequestMapping("/update")
	public void update(@RequestBody Save save) {
		System.out.println(save);
		evService.update(save);
	}
}
